package cn.edu.scau.cmi.chensixiao.javaFX;

import cn.edu.scau.cmi.chensixiao.domain.Insurance;
import cn.edu.scau.cmi.chensixiao.factory.CarInsuranceFactory;
import cn.edu.scau.cmi.chensixiao.factory.DriverInsuranceFactory;
import cn.edu.scau.cmi.chensixiao.factory.InsuranceFactory;
import cn.edu.scau.cmi.chensixiao.factory.OtherInsuranceFactory;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.image.ImageView;

public class FactoryController {
	@FXML
	private ImageView photo;
	@FXML
	private Label nameLabel;
	@FXML
	private Label idLabel;
	@FXML
	private Label insurLabel;
	@FXML
	private ChoiceBox<String> insurType;
	@FXML
	private Button messageButton;
	@FXML
	private TextArea messageText;
	

	public void initialize() {
		insurType.getItems().addAll("车上人员责任险","车辆损失险","其他事故");
		
	}
	
	
	public void buttonOnClick() {
		//new Alert(Alert.AlertType.INFORMATION,"请先选择保险类型").showAndWait();
		InsuranceFactory insuranceFactory = null;
		String insuranceType = insurType.getValue();
		switch(insuranceType) {
		case"车上人员责任险": insuranceFactory = new DriverInsuranceFactory();break;
		case"车辆损失险": insuranceFactory = new CarInsuranceFactory();break;
		case"其他事故": insuranceFactory  = new OtherInsuranceFactory();break;
		}
		if(insuranceFactory!=null) {
			Insurance insurance = insuranceFactory.getInstance();
			messageText.setText(insurance.showMessage());

		}
	}
	
	
}
